﻿using UnityEngine;
using System.Collections;
using DG.Tweening;
public class WallAnimation : MonoBehaviour {

    //public Animator wall;
    AudioSource audioSource ;
    public Vector3 endPoint = new Vector3(0, 1, 0);
    Vector3 startpoint ;
    public void Reset()
    {
        Debug.Log("start point: "+startpoint);
        transform.position = startpoint;
    }
    // Use this for initialization
    void Start () {
        startpoint = transform.position;
        audioSource = GetComponent<AudioSource>();
    }

    //// Update is called once per frame
    //void Update()
    //{
    //    transform.Translate(new Vector3(0, 1, 0));
    //}

    public void Move(float speed)
    {
        if (audioSource)
        {
            audioSource.Play();
        }
        if (transform.position != endPoint)
        {
            transform.DOMove(endPoint, speed);
        }
        else
        {
            transform.DOMove(startpoint, speed);
        }
        
        Debug.Log(transform.position);
    }

}
